<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="/common/common.jsp" %>
<%
    String objid = StringUtil.null2String(request.getParameter("objid"));
    String objmethod=StringUtil.null2String(request.getParameter("objmethod"));
%>
<html>
<head>
    <%@ include file="/common/head.jsp" %>
    <script language="javascript">
        var store;
        var selected = new Array();
        Ext.onReady(function () {
            Ext.QuickTips.init();
            <%if(!pagemenustr.equals("")){%>
            var tb = new Ext.Toolbar();
            tb.render('pagemenubar');
            <%=pagemenustr%>
            <%}%>
            store = new Ext.data.JsonStore({
                url:'${ctx}/ext/com.cinsea.ext.ResearchAction?action=voterlist&objid=<%=objid%>&objmethod=<%=objmethod%>',
                root:'result',
                totalProperty:'totalcount',
                remoteSort:true,
                fields:['username']

            });

            var sm = new Ext.grid.RowSelectionModel();

            var cm = new Ext.grid.ColumnModel([
                {header:"姓名", sortable:false, dataIndex:'username'}
            ]);

            cm.defaultSortable = true;

            var grid = new Ext.grid.GridPanel({
                region:'center',
                store:store,
                cm:cm,
                trackMouseOver:false,
                sm:sm,
                loadMask:true,
                viewConfig:{
                    forceFit:true,
                    enableRowBody:true,
                    sortAscText:'<%=I18n.getText("sortAscText")%>',
                    sortDescText:'<%=I18n.getText("sortDescText")%>',
                    columnsText:'<%=I18n.getText("columnsText")%>',
                    getRowClass:function (record, rowIndex, p, store) {
                        return 'x-grid3-row-collapsed';
                    }
                },
                bbar:new Ext.PagingToolbar({
                    pageSize:20,
                    store:store,
                    displayInfo:true,
                    beforePageText:'<%=I18n.getText("beforePageText")%>',
                    afterPageText:'<%=I18n.getText("afterPageText")%>',
                    firstText:'<%=I18n.getText("firstText")%>',
                    prevText:'<%=I18n.getText("prevText")%>',
                    nextText:'<%=I18n.getText("nextText")%>',
                    lastText:'<%=I18n.getText("lastText")%>',
                    displayMsg:'<%=I18n.getText("displayMsg")%>',
                    emptyMsg:'<%=I18n.getText("emptyMsg")%>'
                })

            });


            //Viewport
            var viewport = new Ext.Viewport({
                layout:'border',
                items:[
                    {region:'north', autoScroll:true, contentEl:'divSearch', split:false},
                    grid
                ]
            });
            onSearch();

        });

        function onDelete() {
            var totalsize = selected.length;
            if (totalsize == 0) {
                Ext.MessageBox.alert('', '<%=I18n.getText("selectConfirm")%>');
                return;
            }
            Ext.MessageBox.confirm('', '<%=I18n.getText("deleteConfirm")%>', function (btn, text) {
                if (btn == 'yes') {
                    Ext.Ajax.request({
                        url:'${ctx}/log.do?action=delete',
                        params:{ids:selected.toString()},
                        success:function () {
                            onSearch();
                        }
                    });
                } else {
                    selected = [];
                    onSearch();
                }
            });


        }
    </script>
</head>
<body>
<div id="divSearch">
    <div id="pagemenubar" style="z-index:100;"></div>
</div>


<script language="javascript">
    function getBrowser(viewurl, inputname, inputspan, isneed) {
        var id;
        try {
            id = showDialog(viewurl);
        } catch (e) {
        }
        if (id != null) {
            if (id[0] != '0') {
                document.getElementById(inputname).value = id[0];
                document.getElementById(inputspan).innerHTML = id[1];
            } else {
                document.getElementById(inputname).value = '';
                if (isneed == '0')
                    document.getElementById(inputspan).innerHTML = '';
                else
                    document.getElementById(inputspan).innerHTML = '<img src=${ctx}/images/base/checkinput.gif>';

            }
        }
    }
    function onSearch() {
        var o = $('#mainForm').serializeArray();
        var data = {};
        for (var i = 0; i < o.length; i++) {
            if (o[i].value != null && o[i].value != "") {
                data[o[i].name] = o[i].value;
            }
        }
        store.baseParams = data;
        store.load({params:{start:0, limit:20}});
    }
</script>
</body>
</html>
